from selenium import webdriver
from pymouse import PyMouse
from pykeyboard import PyKeyboard
from time import sleep


# 鼠标操作
# m = PyMouse()
# m.move(500,500)  # 移动到指定坐标
# m.click(250,300,1,5)  # 左键点击指定坐标
# m.click(133,37,2)  # 右键点击指定坐标
# m.press(250,500)  # 按下
# m.release(300,620)  # 释放


# 键盘操作
# k = PyKeyboard()
# k.press_key('h')  # 按一个键
# k.release_key('h')  # 释放一个键
# k.tap_key('k')  # 按下一个键（相当于按下然后释放）
# k.tap_key("h",5,1)  # 每隔一秒按一次，一共按5次


# 文件操作
# dr=webdriver.Chrome()
# dr.implicitly_wait(5)
# # dr.get('http://192.168.13.54:8848/myhtml2/learn_1.html')
# dr.get('http://localhost:8080/woniusales')
# # dr.maximize_window()
# dr.find_element_by_id('username').send_keys('admin')
# dr.find_element_by_id('password').send_keys('admin123')
# dr.find_element_by_id('verifycode').send_keys('0000')
# dr.find_element_by_xpath('/html/body/div[4]/div/form/div[6]/button').click()
# sleep(0.5)
# dr.find_element_by_xpath('//*[@id="navbar"]/ul[1]/li[2]/a').click()
#
# # dr.find_element_by_xpath('//*[@id="batchfile"]').send_keys(r'E:\woniu\user')
# dr.find_element_by_xpath('//*[@id="batchfile"]/..').click()
# sleep(2)
# kb=PyKeyboard()
# file_name=r"E:\woniu\user"
# kb.type_string(file_name)
# kb.tap_key(kb.enter_key)



# from selenium import webdriver
# from time import sleep
# from pykeyboard import PyKeyboard
# dr=webdriver.Chrome()
# dr.get("http://localhost:8080/woniusales")
# dr.find_element_by_id("username").send_keys("admin")
# dr.find_element_by_id("password").send_keys("admin123")
# dr.find_element_by_id("verifycode").send_keys("0000")
# dr.find_element_by_xpath('//button[@onclick="doLogin(\'null\')"]').click()
# dr.find_element_by_link_text("批次管理").click()
# dr.find_element_by.xpath('//input[@id="batchfile"]/..').click() #有的时候点击上传按钮点不动，点击上级。
# sleep(3)#等上传的文件弹框
# kb=PyKeyboard()
# file_name=r"E:\mytest123.txt"#不要有中文kb.type_string(file_name)#输入路径
# sleep(1)
# kb.tap_key(kb.enter_key)#输入回车
# sleep(5)
# dr.quit()



from selenium import webdriver
from time import sleep

# 在打开浏览器之前添加用户的数据
option=webdriver.ChromeOptions()  # chrome 的操作选项
option.add_argument(r"--user-data-dir=C:\Users\Administrator\AppData\Local\Google\Chrome\User Data1")
# 取消掉浏览器上面的提示
option.add_experimental_option('excludeSwitches',['enable-automation'])
dr = webdriver.Chrome(chrome_options=option)  # 指定上面的环境配置
dr.implicitly_wait(10)
dr.get("http://localhost:8080/woniusales/sell")
sleep(10)
dr.quit()



# from selenium import webdriver
# from time import sleep
#
# dr=webdriver.Chrome()
# dr.implicitly_wait(10)
# dr.get("http://localhost:8080/woniusales/")
# # 添加cookies
# dr.add_cookie({"name":"username","value":"admin"})
# dr.add_cookie({"name":"password","value":"admin123"})
# dr.get('http://localhost:8080/woniusales/sell')
#
# sleep(5)
# dr.quit()












